<?php

class YoutubeVideoComment{
	var $title;
	var $content;
	var $author;
	var $published;
	var $updated;
}

class YoutubeVideoCommentParser{
	var $comments;
	function __construct ( $data ){
		$this->xml = new SimpleXMLElement( $data );
		$c=0; //video count
		if (  !isset( $this->xml->entry ) ) {
			// we are reading a simple entry
			$this->comments[$c] = $this->_readEntry( $this->xml );
			return;
		} else{	
			foreach ( $this->xml->entry as $entry ){
				$this->comments[$c] = $this->_readEntry( $entry );
				$c++;
				}
		}
	}	


	function _readEntry( $data ){
		$comment = new YoutubeVideoComment;
		$comment->title = (string) $data->title;
		$comment->content = (string) $data->content;
		$comment->author = new YoutubeVideoAuthor;
		$comment->author->name = ( string ) $data->author->name;
		$comment->author->uri = ( string ) $data->author->uri;
		$comment->updated = (string) $data->updated;
		$comment->published = (string) $data->published;
		return $comment;
		
	}
}

?>
